package com.jyw.web.controller.system;

import com.jyw.common.annotation.Log;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.system.domain.dto.SysOrderReviewConfigAddDto;
import com.jyw.system.domain.vo.SysOrderReviewConfigAllVo;
import com.jyw.system.enums.OrderReviewDetailEnum;
import com.jyw.system.service.ISysOrderReviewConfigService;
import com.jyw.system.service.ISysOrderReviewDetailConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Created by ZhangCheng on 2023/08/17 (系统工单审核配置)
 */
@Api(tags = "系统工单审核配置")
@RestController
@RequestMapping("/system/orderReviewConfig")
public class SysOrderReviewConfigController {

    @Resource
    private ISysOrderReviewConfigService sysOrderReviewConfigService;

    @Resource
    private ISysOrderReviewDetailConfigService sysOrderReviewDetailConfigService;

    /**
     * 获取系统工单审核配置
     *
     * @return
     */
    @GetMapping("/getConfig")
    @ApiOperation("获取系统工单审核配置")
    public CommonResult<SysOrderReviewConfigAllVo> getConfig() {
        return CommonResult.success(sysOrderReviewConfigService.getConfig());
    }

    /**
     * 保存系统工单审核配置
     *
     * @param sysOrderReviewConfigAddDto
     * @return
     */
    @Log(title = "保存系统工单审核配置", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    @ApiOperation("保存系统工单审核配置")
    public CommonResult add(@RequestBody SysOrderReviewConfigAddDto sysOrderReviewConfigAddDto) {
        sysOrderReviewConfigService.save(sysOrderReviewConfigAddDto);
        return CommonResult.success();
    }


    /**
     * 清空工单审核人员明细
     */
    @Log(title = "清空工单审核人员明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/removeStaff")
    @ApiOperation("清空工单审核人员明细")
    public CommonResult removeStaff() {
        sysOrderReviewDetailConfigService.deleteByType(OrderReviewDetailEnum.STAFF.getValue());
        return CommonResult.success();
    }
}
